#pragma once

#include "common.h"

#include "RenderUtils.h"

class D2DRender
{
public:
	D2DRender(IDXGISwapChain * const sc, IDXGIDevice * const device);
	~D2DRender(void);

	void Update();
	void Draw();

	void ReleaseResizedResources();
	void OnResize();

	void GetID2D1FactoryPtr(ID2D1Factory ** ptr);
	void GetIWICImagingFactoryPtr(IWICImagingFactory ** ptr);
	void GetIDWriteFactoryPtr(IDWriteFactory ** ptr);

private:
	void Init();	

	IDXGISwapChain * swapChain;
	IDXGIDevice * dxgiDevice;

	ID2D1Factory * d2Factory;
	IWICImagingFactory * wicFactory;
	IDWriteFactory * dWriteFactory;

	ID2D1RenderTarget * backBufferRT;
};

inline void D2DRender::GetID2D1FactoryPtr(ID2D1Factory ** ptr)
{
	d2Factory->QueryInterface(__uuidof(ID2D1Factory), reinterpret_cast<void**>(ptr));
}

inline void D2DRender::GetIWICImagingFactoryPtr(IWICImagingFactory ** ptr)
{
	wicFactory->QueryInterface(__uuidof(IWICImagingFactory), reinterpret_cast<void**>(ptr));
}

inline void D2DRender::GetIDWriteFactoryPtr(IDWriteFactory ** ptr)
{
	dWriteFactory->QueryInterface(__uuidof(IDWriteFactory), reinterpret_cast<void**>(ptr));
}
